package org.beetl.sql.clazz;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

public class LegacyTableDesc extends org.beetl.sql.clazz.TableDesc{
	/** 跟table相关的类，必须线程安全，是懒加载的 */
	private final Map<Class, ClassDesc> classes = new ConcurrentHashMap<>();

	public LegacyTableDesc(String name, String remark) {
		super(name, remark);
	}
	
	@Override
	public ClassDesc genClassDesc(Class c, NameConversion nc) {
		ClassDesc classDesc = classes.get(c);
		if(classDesc==null){
			synchronized(classes){
				classDesc = classes.get(c);
				if (classDesc != null) {
					return classDesc;
				}
				classDesc = new LegacyClassDesc(c, this, nc);
				classes.put(c, classDesc);
			}
		}
		return classDesc;
	}

}
